package com.aivin.popuwindowdemo.window;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.HorizontalScrollView;
import com.aivin.popuwindowdemo.R;
import com.aivin.popuwindowdemo.bean.BgDrawable;

/**
 * 微信图片 二级弹窗
 */
public class WxPicDownWindow extends MyBasePopuwindow {
    private HorizontalScrollView scrollView;

    public WxPicDownWindow(Context context) {
        super(context);
        this.setFocusable(true);
        this.setTouchable(true);
        this.setOutsideTouchable(false);
        this.setThisOutTouchCancel(false);
        ColorDrawable dw = new ColorDrawable(Color.TRANSPARENT);
        this.setBackgroundDrawable(dw);

        // 这个宽度可以根据自己的UI设计 自由调节
        int width= dp2px(context ,280);
        int height= dp2px(context ,280);
        this.setWidth(width);
        this.setHeight(height);

        View rootView = initView(context);
        this.setContentView(rootView);
    }

    @SuppressLint("ClickableViewAccessibility")
    private View initView(Context context) {
        View popuwindowRootView = LayoutInflater.from(context).inflate(R.layout.wxpic_down_window_lay, null);

        View savepicAndFollow_wx = popuwindowRootView.findViewById(R.id.savepicAndFollow_wx);
        savepicAndFollow_wx.setBackground(new BgDrawable( 20, Color.parseColor("#236eff") ,Color.parseColor("#5895b4")));
        savepicAndFollow_wx.setOnClickListener(onClickListener);
        return popuwindowRootView;
    }

    private View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int id = v.getId();
            if(id==R.id.savepicAndFollow_wx){
                dismssTheWindow() ;
            }
        }
    };



}
